* Benjamin E. Goldsmith, Yusaku Horiuchi, Takashi Inoguchi
* Replication of "American Foreign Policy and Global Opinion: Who Supported the War in Afghanistan?"
* Journal of Conflict Resolution, Vol. 49, No. 3, pp. 408-429
* Publication Date: June 2005

clear
set memory 20m
set more off
use jcr2005.dta
capture log close
log using jcr2005.log, replace
log off

/* Dependent Variables */

gen Q1_ag = 100*q1a1/(q1a1+q1a2+q1a3)
gen Q1_da = 100*q1a2/(q1a1+q1a2+q1a3)
gen Q2_ag = 100*q2a1/(q2a1+q2a2+q2a3)
gen Q2_da = 100*q2a2/(q2a1+q2a2+q2a3)
egen temp = rmean(q4a1 q4a2 q4a3 q4a4)
gen Q3    = (q4a5-temp)
drop temp
gen Q4_wo = 100*q5a1/(q5a1+q5a2+q5a3)
gen Q4_nw = 100*q5a2/(q5a1+q5a2+q5a3)
* edit cname Q1_* Q2_* Q3 Q4_*

/* Country Dummy Variables */

gen ISR=(cid2=="ISR")
gen ALB=(cid2=="ALB")
gen USA=(cid2=="USA")

/* INTEREST */

gen x1_mdp           = usally_mdp
gen x1_nato          = usally_nato
gen x1_maid          = 1000000*(tma_1997+tma_1998+tma_1999+tma_2000)/econ_gdpr 
gen x1_trade         = ln((trade_im2+trade_ex2)/econ_gdpr)
gen x1_mid_90s       = mid_max90
gen x1_covert        = interventions

/* SOCIALIZATION */

gen x2_incidents     = incidents01
gen x2_gdppc         = ln(cia_gdppc)
gen x2_polity        = ln(polityscore+10)
gen x2_muslim        = muslimpct

/* INFLUENCE */

gen x3_eaid          = 1000000*(tea_1997+tea_1998+tea_1999+tea_2000)/econ_gdpr 
gen x3_press         = 100*(1/freepress)

keep cid* cname Q* x1_* x2_* x3_* ALB ISR USA
ren Q1_ag Q1a
ren Q1_da Q1b
ren Q2_ag Q2a
ren Q2_da Q2b
ren Q4_wo Q4a
ren Q4_nw Q4b

la var cid1 "Country ID 1"
la var cid2 "Country ID 2"
la var cname "Country Name"
la var Q1a "Q1a"
la var Q1b "Q1b"
la var Q2a "Q2a"
la var Q2b "Q2b"
la var Q3 "Q3"
la var Q4a "Q4a"
la var Q4b "Q4b"
la var ISR "Israel Dummy"
la var ALB "Albania Dummy"
la var USA "USA Dummy"
la var x1_mdp "Interests, Mutual defense pact with the US"
la var x1_nato "Interests, NATO member"
la var x1_maid "Interests, Military aid from the US"
la var x1_trade "Interests, Trade with the US"
la var x1_mid_90s "Interests, Highest MID with the US"
la var x1_covert "Interests, US intervention"
la var x2_incidents "Socialization, Past terrorist incidents"
la var x2_gdppc "Socialization, GDP per capita"
la var x2_polity "Socialization, polity score"
la var x2_muslim "Socialization, Muslim population"
la var x3_eaid "Influence, Economic aid from the US"
la var x3_press "Influence, Press freedom"

/* Regressions */

drop if ALB==1 | ISR==1 | USA==1

capture program drop mycode
capture program define mycode
  reg `1' x1_* x2_* x3_*, robust
end

mycode Q1a
mycode Q1b
mycode Q2a
mycode Q2b
mycode Q3
mycode Q4a
mycode Q4b 

/* Summary Statistics */

sum x1_* x2_* x3_*
qui mycode Q4a
vif

